﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIManager : MonoBehaviour
{
    public static UIManager Instance;
    public IUIView mainPanel;
    public IUIView selectSavePanel;
    public IUIView modelSelectPanel;
    public IUIView settingPanel;
    public IUIView keySettiingPanel;
    public IUIView audioSettingPanel;
    public IUIView loadingView;
    public CombatView combatView;
    public IUIView contentListView;
    public UIBindTransPos saveTip;
    public IUIView gameDesPanel;
    Image bg;
    Canvas canvas;

    private void Awake()
    {
        if (UIManager.Instance!=null)
        {
            Destroy(this.gameObject);
            return;
        }
        canvas = GetComponent<Canvas>();

        DontDestroyOnLoad(this.gameObject);
        mainPanel.Initinalize();
        selectSavePanel.Initinalize();
        modelSelectPanel.Initinalize();
        settingPanel.Initinalize();
        keySettiingPanel.Initinalize();
        audioSettingPanel.Initinalize();
        contentListView.Initinalize();
        gameDesPanel.Initinalize();
        bg = transform.Find("BG").GetComponent<Image>();
        Instance = this;

   
    }



    private void Update()
    {
        if (canvas!=null)
        {
            canvas.worldCamera = Camera.main;
        }
    }
    public void setBg(bool isShow)
    {
        bg.gameObject.SetActive(isShow);
    }
    public void OpenSaveTip(string text,Transform trans,Vector3 offset)
    {
        saveTip.GetComponent<Text>().text = text;

        saveTip.Bind(trans,offset,canvas);
    }
    public  void CloseSaveTip()
    {
        saveTip.gameObject.SetActive(false);
    }

    public Vector3 GetLeftTopPos()
    {
        return combatView.transform.GetChild(0).transform.position;
    }
 

}